import org.springframework.web.multipart.commons.*

class BenjaminSasseemTests extends GroovyTestCase {


	//HW3 unit tests for Benjamin Sasseem


	//---------------------------------------------------------------------------------
	// tests valid and invalid picture types (used when importing a new image)
	//---------------------------------------------------------------------------------



	//pass in file that is not a valid type
    void testIsFileTypeValidPicture() {

		CommonsMultipartFile invalidFile = new CommonsMultipartFile(AppConstant.IMAGE_DIRECTORY + "test.doc")
		def im = new ImageManager()
		assert im.isFileTypeValidPicture( invalidFile ) == false
	}


	//pass in null instead of file
	void testIsFileTypeValidPicture2() {

		CommonsMultipartFile nullFile = new CommonsMultipartFile(null)
		def im = new ImageManager()
		assert im.isFileTypeValidPicture( nullFile ) == false
	}


	//pass in valid file (jpg)
	void testIsFileTypeValidPicture3() {

		CommonsMultipartFile validJpgFile = new CommonsMultipartFile(AppConstant.IMAGE_DIRECTORY + "testpicture.jpg")
		def im = new ImageManager()
		assert im.isFileTypeValidPicture( validJpgFile ) == true
	}


	//pass in valid file (gif)
	void testIsFileTypeValidPicture4() {

		CommonsMultipartFile validGifFile = new CommonsMultipartFile(AppConstant.IMAGE_DIRECTORY + "testpicture.gif")
		def im = new ImageManager()
		assert im.isFileTypeValidPicture( validGifFile ) == true
	}


}
